home *** CD-ROM | disk | FTP | other *** search
- //////////////////////////
- // Harrow Software 1996
- // Bitmap examples
-
- ///////////////////////////
- // (1) - Loading a bitmap
-
- // The following instruction will load a bitmap from disk
- // and assign it to the "my_bitmap" handle. The bitmap object
- // contains the bits of the image, its palette, and its resolution
-
- load "example.gif" bitmap my_bitmap
-
- message "width = ", my_bitmap.xlen // bitmap width
- message "height = ", my_bitmap.ylen // bitmap height
- switch my_bitmap.mode // color mode
- case PAL
- message "colors = 256"
- case RGB16
- message "colors = 65536"
- case RGB24
- message "colors = 24 million"
-
- // The palette returned from the bitmap object will be a
- // 2 dimensional array of the form [256][3]
-
- my_palette = @my_bitmap.palette // bitmap palette
- message "palette[0] = ",my_palette[0][0],",",my_palette[0][1],",",my_palette[0][2]
-
- //////////////////////////////
- // (2) - Displaying a bitmap
-
- // Bitmaps without palettes are easy to display. If the bitmap
- // does have a palette and if you wish to display it with its
- // full palette
-
- display bitmap my_bitmap
-
- // You can display the bitmap so that its colors are remapped to
- // the existing palette.
-
- display bitmap my_bitmap mode DISPLAY_REMAP
-
- // Otherwise you can remap the colors of the bitmap to the
- // existing graphics window palette and then display the bitmap
- // without any mapping. This is faster when you need to
- // display the bitmap more than once
-
- remap bitmap my_bitmap
- display bitmap my_bitmap mode DISPLAY_DIRECT
-
- // If you display a bitmap during a multimedia presentation and
- // you need integration with the palette management system then
- // the following statement will allocate colors before it remaps
- // and displays the bitmap.
-
- project bitmap my_bitmap
-
- // Later you may need to deallocate the palette colors used by
- // this bitmap. The following instruction will release all colors
- // used by every bitmap displayed by this script
-
- decompose
-
- //////////////////////////////
- // (3) - Pixels
-
- // The color of each pixel in a bitmap can be found by treating
- // the bitmap as an array of the form [xmax][ymax][3]
-
- message "The red, green and blue values of the first pixel are "
- message my_bitmap[0][0][0],", ",my_bitmap[0][0][1],", ",my_bitmap[0][0][2]
-
- // Colors may also be assigned new red, green or blue values
-
- my_bitmap[0][0][0] = 255, 255, 255
-
-